/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package rpt.lib; 
/**
 */

/*
 * CLookAndFeel.java is a Java SE 6 example that requires
 * one other file (TestTheme.java).
 */

//import ch.randelshofer.quaqua.QuaquaManager;
import javax.swing.*;
import javax.swing.plaf.metal.*;

public class CLookAndFeel {
    private JFrame fJanelaPrincipal;
    private static String labelPrefix = "Number of button clicks: ";
    final JLabel label = new JLabel(labelPrefix + "0    ");

    // Specify the look and feel to use by defining the vLookAndFeel constant
    // Valid values are: null (use the default), "Metal", "System", "Motif",
    // and "GTK"

    //final static String vLookAndFeel = "Metal";

    // If you choose the Metal L&F, you can also choose a theme.
    // Specify the theme to use by defining the THEME constant
    // Valid values are: "DefaultMetal", "Ocean",  and "Test"

    //final static String THEME = "Ocean";

    public CLookAndFeel(JFrame aFrame, String aLookAndFeel) {
        super();
        fJanelaPrincipal = aFrame;
        setLookAndFeel(aLookAndFeel,"Ocean");
    }

    public void setLookAndFeel(String aLookAndFeel, String aTema) {
        String vLookAndFeel = null;

        if (aLookAndFeel != null) {
            if (aLookAndFeel.equals("Metal")) {
                vLookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
              //  an alternative way to set the Metal L&F is to replace the
              // previous line with:
              // vLookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel";

            }
            else if (aLookAndFeel.equals("Substance")) {
                vLookAndFeel = " org.pushingpixels.substance.internal.ui";
            }
            else if (aLookAndFeel.equals("System")) {
                vLookAndFeel = UIManager.getSystemLookAndFeelClassName();
            }
            else if (aLookAndFeel.equals("Motif")) {
                vLookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
            }
            else if (aLookAndFeel.equals("GTK")) {
                vLookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
            }
/*
            else if (vLookAndFeel.equals("Substance")) {
                vLookAndFeel = new SubstanceBusinessLookAndFeel();
            }
*/
            else if (aLookAndFeel.equals("QuaQua")) {
                //vLookAndFeel = QuaquaManager.getLookAndFeelClassName();
            }
            else if (aLookAndFeel.equals("Napkin")) {
                vLookAndFeel = "net.sourceforge.napkinlaf.NapkinLookAndFeel";
            }
            else {
                System.err.println("Unexpected value of vLookAndFeel specified: "
                                   + aLookAndFeel);
                vLookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
            }
            if (vLookAndFeel != null)
                try {
                    // If L&F = "Metal", set the theme
                    if (aLookAndFeel.equals("Metal")) {
                      if (aTema.equals("DefaultMetal"))
                         MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
                      else if (aTema.equals("Ocean"))
                         MetalLookAndFeel.setCurrentTheme(new OceanTheme());
                      UIManager.setLookAndFeel(new MetalLookAndFeel());
                      SwingUtilities.updateComponentTreeUI(fJanelaPrincipal);
                      fJanelaPrincipal.pack();
                    }
                    else {
                        UIManager.setLookAndFeel(vLookAndFeel);
                        SwingUtilities.updateComponentTreeUI(fJanelaPrincipal);
                        fJanelaPrincipal.pack();
                    }
                }

                catch (ClassNotFoundException e) {
                    System.err.println("Couldn't find class for specified look and feel:"
                                       + vLookAndFeel);
                    System.err.println("Did you include the L&F library in the class path?");
                    System.err.println("Using the default look and feel.");
                }

                catch (UnsupportedLookAndFeelException e) {
                    System.err.println("Can't use the specified look and feel ("
                                       + vLookAndFeel
                                       + ") on this platform.");
                    System.err.println("Using the default look and feel.");
                }

                catch (Exception e) {
                    System.err.println("Couldn't get specified look and feel ("
                                       + vLookAndFeel
                                       + "), for some reason.");
                    System.err.println("Using the default look and feel.");
                    e.printStackTrace();
                }
        }
    }
}
